﻿using System;
using System.Collections.Generic;
using System.Text;

namespace VkSample49
{
    public class BeltData
    {
        public uint VCount { get; set; }

        public float[] Data { get; set; }

        public void GenVertexData()
        {
            int n1 = 3;
            int n2 = 5;
            VCount = (uint)(2 * (n1 + n2 + 2) + 2);
            Data = new float[VCount * 6];
            float angdegBegin1 = 0;
            float angdegEnd1 = 90;
            float angdegSpan1 = (angdegEnd1 - angdegBegin1) / n1;
            float angdegBegin2 = 180;
            float angdegEnd2 = 270;
            float angdegSpan2 = (angdegEnd2 - angdegBegin2) / n2;
            int count = 0;
            for(float angdeg = angdegBegin1; angdeg <= angdegEnd1; angdeg += angdegSpan1)
            {
                float angrad = angdeg / 180.0f * MathF.PI;
                Data[count++] = -0.6f * 80.0f * MathF.Sin(angrad);
                Data[count++] = 0.6f * 80.0f * MathF.Cos(angrad);
                Data[count++] = 0;
                Data[count++] = 1;
                Data[count++] = 1;
                Data[count++] = 1;
                Data[count++] = -80 * MathF.Sin(angrad);
                Data[count++] = 80 * MathF.Cos(angrad);
                Data[count++] = 0;
                Data[count++] = 0;
                Data[count++] = 1;
                Data[count++] = 1;
            }
            float old = Data[count - 6];
            Data[count++] = old;
            old = Data[count - 6];
            Data[count++] = old;
            Data[count++] = 0;
            Data[count++] = 1;
            Data[count++] = 0;
            Data[count++] = 0;
            for(float angdeg = angdegBegin2; angdeg <= angdegEnd2; angdeg += angdegSpan2)
            {
                float angrad = angdeg / 180.0f * MathF.PI;
                if(angdeg == angdegBegin2)
                {
                    Data[count++] = -0.6f * 80.0f * MathF.Sin(angrad);
                    Data[count++] = 0.6f * 80.0f * MathF.Cos(angrad);
                    Data[count++] = 0;
                    Data[count++] = 0;
                    Data[count++] = 1;
                    Data[count++] = 0;
                }
                Data[count++] = -0.6f * 80.0f * MathF.Sin(angrad);
                Data[count++] = 0.6f * 80.0f * MathF.Cos(angrad);
                Data[count++] = 0;
                Data[count++] = 1;
                Data[count++] = 1;
                Data[count++] = 1;
                Data[count++] = -80 * MathF.Sin(angrad);
                Data[count++] = 80 * MathF.Cos(angrad);
                Data[count++] = 0;
                Data[count++] = 0;
                Data[count++] = 1;
                Data[count++] = 1;
            }

        }
    }
}
